package cc.vv.btpartyjob.partyservice.adapter

import android.annotation.SuppressLint
import android.widget.ImageView
import android.widget.TextView
import cc.vv.baselibrary.adapter.SimpleCommonAdapter
import cc.vv.baselibrary.adapter.holder.ExtendViewHolder
import cc.vv.baselibrary.view.LKCircleImageView
import cc.vv.baselibrary.view.OvalImageView
import cc.vv.btpartyjob.partyservice.R
import cc.vv.btpartyjob.partyservice.module.bean.VolunteerBean
import cc.vv.lkimagecomponent2.LKImage
import cc.vv.lkimagecomponent2.lib.mode.ScaleMode

/**
 * 志愿者adapter
 * Created by Chen.qi on 2018/10/24.
 */
class VolunteerAdapter(layoutResId: Int) : SimpleCommonAdapter<VolunteerBean>(layoutResId) {
    @SuppressLint("SetTextI18n")
    override fun convert(helper: ExtendViewHolder, item: VolunteerBean, position: Int) {
        //头像
        val viewHead = helper.getView<LKCircleImageView>(R.id.lkv_ivpT_perHeadImg)
        LKImage.load().load(item.faceUrl).placeHolder(R.mipmap.icon_def_image).error(R.mipmap.icon_def_image)
                .scale(ScaleMode.CENTER_CROP).into(viewHead)

        //姓名
        helper.getView<TextView>(R.id.tv_ivpT_perName)?.text = item.name

        //性别图片
        val imgView = helper.getView<ImageView>(R.id.iv_ivpT_sex)
        if (item.sex == 0) {
            //男
            imgView?.setImageResource(R.mipmap.icon_party_man)
        } else {
            //女
            imgView?.setImageResource(R.mipmap.icon_party_woman)
        }

        //所属位置
        helper.getView<TextView>(R.id.tv_ivpT_personPos)?.text = item.volunteerType

        //电话
        helper.getView<TextView>(R.id.tv_ivpT_telPhone)?.text = item.mobile

    }
}